﻿using Client.Windows;
using System.Diagnostics;
using System.Windows;

namespace Client {
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application {
        public App() {
            KeepSingle();
        }

        private void KeepSingle() {
            // Get Reference to the current Process
            Process thisProc = Process.GetCurrentProcess();
            // Check how many total processes have the same name as the current one
            if (Process.GetProcessesByName(thisProc.ProcessName).Length > 1) {
                // If ther is more than one, than it is already running.
                MessageBox.Show("程序已经在运行中，请勿重复运行！", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                Application.Current.Shutdown();
                return;
            }
            new CircleBall().Show();
        }
    }
}
